package com.ueip.backend.controller;

import com.ueip.backend.service.UserService;
import com.ueip.backend.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/add")
    Result add(@RequestParam Map<String, String> data) {
        return userService.add(data);
    }

    @PostMapping("/delete/by/id")
    Result deleteById(@RequestParam Map<String, String> data) {
        return userService.deleteById(data);
    }

    @GetMapping("/get/all")
    Result getAll() {
        return userService.getAll();
    }

    @PostMapping("/register")
    Result register (@RequestBody Map<String, String> data) {
        return userService.register(data);
    }

    @PostMapping("/login")
    Result login (@RequestBody Map<String, String> data) {
        return userService.login(data);
    }

    @PostMapping("/get/user/info")
    Result getInfo() {
        return userService.getInfo();
    }

    @PostMapping("/update/password")
    Result updatePassword(@RequestBody Map<String, String> data) {
        return userService.updatePassword(data);
    }
}
